package com.dmap.analysispoint.service.impl;

import com.dmap.base.units.DateUtil;
import com.dmap.analysispoint.bo.DateAndNumBo;
import com.dmap.analysispoint.constants.BurialPointConstant;
import com.dmap.analysispoint.controller.background.param.CountParam;
import com.dmap.analysispoint.service.*;
import com.dmap.analysispoint.utils.ObjectTransitionArrayListUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * \* @author:zhouhao
 * \* Date:13/05/2018
 * \* Description:
 * \*
 */

@Service
public class RealTimeCountAnalysisServiceImpl implements RealTimeCountAnalysisService {

    @Resource
    private PhoneInfoAnalysisService phoneInfoAnalysisService;
    @Resource
    private UserInfoAnalysisService userInfoAnalysisService;
    @Resource
    private EquipmentInfoAnalysisService equipmentInfoAnalysisService;
    @Resource
    private ParamDoService paramDoService;

    @Override
    public List<List> realTimeCountAnalysisList(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        //获得当天/昨天同时间段的新增手机数、活跃手机数、活跃用户数、启动次数
        List<List> countPhoneUserNumList = this.countPhoneUserNumList(param);

        //获得实时分析模块整体趋势部分所需要的所有信息和数据
        List<List> overallTrendList = this.overallTrendList(param);

        //实时分析模块详细数据部分需要到所有信息和数据
        List<List> detailDataList = this.detailDataList(param);
        List<List> realTimeCountAnalysisList = new ArrayList<>();
        realTimeCountAnalysisList.add(countPhoneUserNumList);
        realTimeCountAnalysisList.add(overallTrendList);
        realTimeCountAnalysisList.add(detailDataList);
        return realTimeCountAnalysisList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return countActivePhoneList                      当天/昨天同时间段的新增手机数、活跃手机数、活跃用户数、启动次数
     *         其中里面分别为： 1.todayList                 当天的新增手机数、活跃手机数、活跃用户数、启动次数
     *                       2.yesterdayList             昨天同时间段的新增手机数、活跃手机数、活跃用户数、启动次数
     */
    private List<List> countPhoneUserNumList(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        CountParam countParam = paramDoService.getParam(param);
        //当天的新增手机数、活跃手机数、活跃用户数、启动次数
        int addPhoneNum = phoneInfoAnalysisService.countAddPhoneNum(countParam);
        int activePhoneNum = phoneInfoAnalysisService.countActivePhoneNumByHour(countParam);
        int activeUserNum = userInfoAnalysisService.countActiveUserNumByHour(countParam);
        int startUpNum = userInfoAnalysisService.countStartUpNumByHour(countParam);
        List<Integer> todayList = new ArrayList<>();
        todayList.add(0, addPhoneNum);
        todayList.add(1, activePhoneNum);
        todayList.add(2, activeUserNum);
        todayList.add(3, startUpNum);

        //昨天同时间段的新增手机数、活跃手机数、活跃用户数、启动次数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS - 1);
        addPhoneNum = phoneInfoAnalysisService.countAddPhoneNum(countParam);
        activePhoneNum = phoneInfoAnalysisService.countActivePhoneNumByHour(countParam);
        activeUserNum = userInfoAnalysisService.countActiveUserNumByHour(countParam);
        startUpNum = userInfoAnalysisService.countStartUpNumByHour(countParam);
        List<Integer> yesterdayList = new ArrayList<>();
        yesterdayList.add(0, addPhoneNum);
        yesterdayList.add(1, activePhoneNum);
        yesterdayList.add(2, activeUserNum);
        yesterdayList.add(3, startUpNum);
        List<List> countPhoneUserNumList = new ArrayList<>();
        countPhoneUserNumList.add(todayList);
        countPhoneUserNumList.add(yesterdayList);
        return countPhoneUserNumList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return overallTrendList                           实时分析模块整体趋势部分所需要的所有信息和数据
     *         其中里面分别为： 1.addPhoneList               当天/昨天/七天前/三十天前按小时分组新增手机数
     *                       2.addUserList                当天/昨天/七天前/三十天前按小时分组新增用户数
     *                       3.addEquipmentList           当天/昨天/七天前/三十天前按小时分组新增设备数
     *                       4.activePhoneList            当天/昨天/七天前/三十天前按小时分组活跃手机数
     *                       5.activeUserList             当天/昨天/七天前/三十天前按小时分组活跃用户数
     *                       6.activeEquipmentList        当天/昨天/七天前/三十天前按小时分组活跃设备数
     *                       7.startUpList                当天/昨天/七天前/三十天前按小时分组启动次数
     */
    private List<List> overallTrendList(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        List<List> addPhoneList = this.countAddPhoneNum(param);
        List<List> addUserList = this.countAddUserNum(param);
        List<List> addEquipmentList = this.countAddEquipmentNum(param);
        List<List> activePhoneList = this.countActivePhoneNum(param);
        List<List> activeUserList = this.countActiveUserNum(param);
        List<List> activeEquipmentList = this.countActiveEquipmentNum(param);
        List<List> startUpList = this.countStartUpNum(param);
        List<List> overallTrendList = new ArrayList<>();
        overallTrendList.add(addPhoneList);
        overallTrendList.add(addUserList);
        overallTrendList.add(addEquipmentList);
        overallTrendList.add(activePhoneList);
        overallTrendList.add(activeUserList);
        overallTrendList.add(activeEquipmentList);
        overallTrendList.add(startUpList);
        return overallTrendList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return addPhoneList                              当天/昨天/七天前/三十天前按小时分组的新增手机数
     *         其中里面分别为： 1.todayList                 当天按小时分组新增手机数
     *                       2.yesterdayList             昨天按小时分组新增手机数
     *                       3.sevenDayList              七天前按小时分组新增手机数
     *                       4.thirtyDayList             三十天前按小时分组新增手机数
     */
    private List<List> countAddPhoneNum(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        CountParam countParam = paramDoService.getParam(param);

        //当天按小时分组新增手机数
        List<List> todayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(phoneInfoAnalysisService.countAddPhoneList(countParam));

        //昨天按小时分组新增手机数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS);
        countParam.setEndTime(DateUtil.getToday0() -  1);
        List<List> yesterdayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(phoneInfoAnalysisService.countAddPhoneList(countParam));

        //七天前按小时分组新增手机数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        List<List> sevenDayList= ObjectTransitionArrayListUtils.objectTransitionArrayList(phoneInfoAnalysisService.countAddPhoneList(countParam));

        //三十天前按小时分组新增手机数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        List<List> thirtyDayList= ObjectTransitionArrayListUtils.objectTransitionArrayList(phoneInfoAnalysisService.countAddPhoneList(countParam));
        List<List> addPhoneList = new ArrayList<>();
        addPhoneList.add(todayList);
        addPhoneList.add(yesterdayList);
        addPhoneList.add(sevenDayList);
        addPhoneList.add(thirtyDayList);
        return addPhoneList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return addPhoneList                              当天/昨天/七天前/三十天前按小时分组的新增用户数
     *         其中里面分别为： 1.todayList                 当天按小时分组新增用户数
     *                       2.yesterdayList             昨天按小时分组新增用户数
     *                       3.sevenDayList              七天前按小时分组新增用户数
     *                       4.thirtyDayList             三十天前按小时分组新增用户数
     */
    private List<List> countAddUserNum(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        CountParam countParam = paramDoService.getParam(param);

        //当天按小时分组新增用户数
        List<List> todayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countAddUserList(countParam));

        //昨天按小时分组新增用户数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS);
        countParam.setEndTime(DateUtil.getToday0() -  1);
        List<List> yesterdayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countAddUserList(countParam));

        //七天前按小时分组新增用户数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        List<List> sevenDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countAddUserList(countParam));

        //三十天前按小时分组新增用户数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        List<List> thirtyDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countAddUserList(countParam));
        List<List> addUserList = new ArrayList<>();
        addUserList.add(todayList);
        addUserList.add(yesterdayList);
        addUserList.add(sevenDayList);
        addUserList.add(thirtyDayList);
        return addUserList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return addPhoneList                              当天/昨天/七天前/三十天前按小时分组的新增设备数
     *         其中里面分别为： 1.todayList                 当天按小时分组新增设备数
     *                       2.yesterdayList             昨天按小时分组新增设备数
     *                       3.sevenDayList              七天前按小时分组新增设备数
     *                       4.thirtyDayList             三十天前按小时分组新增设备数
     */
    private List<List> countAddEquipmentNum(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        CountParam countParam = paramDoService.getParam(param);

        //当天按小时分组新增设备数
        List<List> todayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(equipmentInfoAnalysisService.countAddEquipmentNumList(countParam));

        //昨天按小时分组新增设备数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS);
        countParam.setEndTime(DateUtil.getToday0() -  1);
        List<List> yesterdayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(equipmentInfoAnalysisService.countAddEquipmentNumList(countParam));

        //七天前按小时分组新增设备数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        List<List> sevenDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(equipmentInfoAnalysisService.countAddEquipmentNumList(countParam));

        //三十天前按小时分组新增设备数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        List<List> thirtyDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(equipmentInfoAnalysisService.countAddEquipmentNumList(countParam));
        List<List> addEquipmentList = new ArrayList<>();
        addEquipmentList.add(todayList);
        addEquipmentList.add(yesterdayList);
        addEquipmentList.add(sevenDayList);
        addEquipmentList.add(thirtyDayList);
        return addEquipmentList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return addPhoneList                              当天/昨天/七天前/三十天前按小时分组的活跃手机数
     *         其中里面分别为： 1.todayList                 当天按小时分组活跃手机数
     *                       2.yesterdayList             昨天按小时分组活跃手机数
     *                       3.sevenDayList              七天前按小时分组活跃手机数
     *                       4.thirtyDayList             三十天前按小时分组活跃手机数
     */
    private List<List> countActivePhoneNum(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        CountParam countParam = paramDoService.getParam(param);

        //当天按小时分组活跃手机数
        List<List> todayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(phoneInfoAnalysisService.countActivePhoneListByHour(countParam));

        //昨天按小时分组活跃手机数
        countParam.setEndTime(countParam.getStartTime() - 1);
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS);
        List<List> yesterdayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(phoneInfoAnalysisService.countActivePhoneListByHour(countParam));

        //七天前按小时分组活跃手机数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        List<List> sevenDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(phoneInfoAnalysisService.countActivePhoneListByHour(countParam));

        //三十天前按小时分组活跃手机数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        List<List> thirtyDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(phoneInfoAnalysisService.countActivePhoneListByHour(countParam));
        List<List> activePhoneList = new ArrayList<>();
        activePhoneList.add(todayList);
        activePhoneList.add(yesterdayList);
        activePhoneList.add(sevenDayList);
        activePhoneList.add(thirtyDayList);
        return activePhoneList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return addPhoneList                              当天/昨天/七天前/三十天前按小时分组的活跃用户数
     *         其中里面分别为： 1.todayList                 当天按小时分组活跃用户数
     *                       2.yesterdayList             昨天按小时分组活跃用户数
     *                       3.sevenDayList              七天前按小时分组活跃用户数
     *                       4.thirtyDayList             三十天前按小时分组活跃用户数
     */
    private List<List> countActiveUserNum(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        CountParam countParam = paramDoService.getParam(param);

        //当天按小时分组活跃用户数
        List<List> todayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countActiveUserListByHour(countParam));

        //昨天按小时分组活跃用户数
        countParam.setEndTime(countParam.getStartTime() - 1);
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS);
        List<List> yesterdayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countActiveUserListByHour(countParam));

        //七天前按小时分组活跃用户数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        List<List> sevenDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countActiveUserListByHour(countParam));

        //三十天前按小时分组活跃用户数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        List<List> thirtyDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countActiveUserListByHour(countParam));
        List<List> activeUserList = new ArrayList<>();
        activeUserList.add(todayList);
        activeUserList.add(yesterdayList);
        activeUserList.add(sevenDayList);
        activeUserList.add(thirtyDayList);
        return activeUserList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return addPhoneList                              当天/昨天/七天前/三十天前按小时分组的活跃设备数
     *         其中里面分别为： 1.todayList                 当天按小时分组活跃设备数
     *                       2.yesterdayList             昨天按小时分组活跃设备数
     *                       3.sevenDayList              七天前按小时分组活跃设备数
     *                       4.thirtyDayList             三十天前按小时分组活跃设备数
     */
    private List<List> countActiveEquipmentNum(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        CountParam countParam = paramDoService.getParam(param);

        //当天按小时分组活跃设备数
        List<List> todayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(equipmentInfoAnalysisService.countActiveEquipmentList(countParam));

        //昨天按小时分组活跃设备数
        countParam.setEndTime(countParam.getStartTime() - 1);
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS);
        List<List> yesterdayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(equipmentInfoAnalysisService.countActiveEquipmentList(countParam));

        //七天前按小时分组活跃设备数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        List<List> sevenDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(equipmentInfoAnalysisService.countActiveEquipmentList(countParam));

        //三十天前按小时分组活跃设备数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        List<List> thirtyDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(equipmentInfoAnalysisService.countActiveEquipmentList(countParam));
        List<List> activeEquipmentList = new ArrayList<>();
        activeEquipmentList.add(todayList);
        activeEquipmentList.add(yesterdayList);
        activeEquipmentList.add(sevenDayList);
        activeEquipmentList.add(thirtyDayList);
        return activeEquipmentList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return addPhoneList                              当天/昨天/七天前/三十天前按小时分组的启动次数
     *         其中里面分别为： 1.todayList                 当天按小时分组启动次数
     *                       2.yesterdayList             昨天按小时分组启动次数
     *                       3.sevenDayList              七天前按小时分组启动次数
     *                       4.thirtyDayList             三十天前按小时分组启动次数
     */
    private List<List> countStartUpNum(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        CountParam countParam = paramDoService.getParam(param);

        //当天按小时分组启动次数
        List<List> todayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countStartUpNumList(countParam));

        //昨天按小时分组启动次数
        countParam.setEndTime(countParam.getStartTime() - 1);
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS);
        List<List> yesterdayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countStartUpNumList(countParam));

        //七天前按小时分组启动次数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 6);
        List<List> sevenDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countStartUpNumList(countParam));

        //三十天前按小时分组启动次数
        countParam.setStartTime(countParam.getStartTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        countParam.setEndTime(countParam.getEndTime() - BurialPointConstant.ONE_DAY_TIME_MILLISECONDS * 23);
        List<List> thirtyDayList = ObjectTransitionArrayListUtils.objectTransitionArrayList(userInfoAnalysisService.countStartUpNumList(countParam));
        List<List> startUpList = new ArrayList<>();
        startUpList.add(todayList);
        startUpList.add(yesterdayList);
        startUpList.add(sevenDayList);
        startUpList.add(thirtyDayList);
        return startUpList;
    }

    /**
     *
     * @param param String companyId;       公司编号
     *              String place;           渠道
     *              String projectId;       项目编号
     *              String firmwareId;      设备固件编号
     *              String firmwareVersion; 设备固件版本号
     *              String appVersion;      app版本号
     *              Long startTime;         查询的开始时间
     *              Long endTime;           查询的结束时间
     *
     * @return detailDataList              实时分析模块详细数据部分需要到所有信息和数据
     *                                     其中里面分别为当天按小时分组将新增手机数、新增用户数、新增设备数、活跃手机数、活跃用户数、活跃设备数、启动次数数据按小时的时间节点拼装的list
     */
    private List<List> detailDataList(CountParam param) {
        if (param == null) {
            return Collections.emptyList();
        }
        CountParam countParam = paramDoService.getParam(param);
        //获取拼装detailDataList需要所有数据
        List<DateAndNumBo> addPhoneList = phoneInfoAnalysisService.countAddPhoneList(countParam);
        List<DateAndNumBo> addUserList = userInfoAnalysisService.countAddUserList(countParam);
        List<DateAndNumBo> addEquipmentNumList = equipmentInfoAnalysisService.countAddEquipmentNumList(countParam);
        List<DateAndNumBo> activePhoneList = phoneInfoAnalysisService.countActivePhoneListByHour(countParam);
        List<DateAndNumBo> activeUserList = userInfoAnalysisService.countActiveUserListByHour(countParam);
        List<DateAndNumBo> activeEquipmentList = equipmentInfoAnalysisService.countActiveEquipmentList(countParam);
        List<DateAndNumBo> startUpList = userInfoAnalysisService.countStartUpNumList(countParam);
        List<List> detailDataList = new ArrayList<>();
        long timePoint = countParam.getStartTime();
        //对获取的数据进行循环处理，保证数据和时间节点统一
        while (timePoint<countParam.getEndTime()){
            List<Long> summarizeList = new ArrayList<>();
            for (int i = 0;i < 8;i++) {
                summarizeList.add(i,(long) 0);
            }
            for (int i = 0;i < addPhoneList.size();i++) {
                DateAndNumBo dateAndNumBo = addPhoneList.get(i);
                if (timePoint == dateAndNumBo.getTimePoint()) {
                    summarizeList.set(1, Long.valueOf(dateAndNumBo.getNum()));
                    continue;
                }
            }

            for (int i = 0;i < addUserList.size();i++) {
                DateAndNumBo dateAndNumBo = addUserList.get(i);
                if (timePoint == dateAndNumBo.getTimePoint()) {
                    summarizeList.set(2,Long.valueOf(dateAndNumBo.getNum()));
                    continue;
                }
            }

            for (int i = 0;i < addEquipmentNumList.size();i++) {
                DateAndNumBo dateAndNumBo = addEquipmentNumList.get(i);
                if (timePoint == dateAndNumBo.getTimePoint()) {
                    summarizeList.set(3,Long.valueOf(dateAndNumBo.getNum()));
                    continue;
                }
            }

            for (int i = 0;i < activePhoneList.size();i++) {
                DateAndNumBo dateAndNumBo = activePhoneList.get(i);
                if (timePoint == dateAndNumBo.getTimePoint()) {
                    summarizeList.set(4,Long.valueOf(dateAndNumBo.getNum()));
                    continue;
                }
            }

            for (int i = 0;i < activeUserList.size();i++) {
                DateAndNumBo dateAndNumBo = activeUserList.get(i);
                if (timePoint == dateAndNumBo.getTimePoint()) {
                    summarizeList.set(5,Long.valueOf(dateAndNumBo.getNum()));
                    continue;
                }
            }

            for (int i = 0;i < activeEquipmentList.size();i++) {
                DateAndNumBo dateAndNumBo = activeEquipmentList.get(i);
                if (timePoint == dateAndNumBo.getTimePoint()) {
                    summarizeList.set(6,Long.valueOf(dateAndNumBo.getNum()));
                    continue;
                }
            }

            for (int i = 0;i < startUpList.size();i++) {
                DateAndNumBo dateAndNumBo = startUpList.get(i);
                if (timePoint == dateAndNumBo.getTimePoint()) {
                    summarizeList.set(7,Long.valueOf(dateAndNumBo.getNum()));
                    continue;
                }
            }
            summarizeList.set(0,timePoint);
            detailDataList.add(summarizeList);
            timePoint = timePoint + 3600;
        }

        return detailDataList;
    }

}
